<%@ LANGUAGE="VBSCRIPT" %>
<%'  ------------------------------------------------------------
  '  doccheckin.asp 
  '  ------------------------------------------------------------
  '  VCS INFO:
  '  
  '  $Revision:   1.28  $
  '  $Date:   05 Dec 2000 14:01:18  $
  '  $Author:   vpham  $
  '  $Workfile:   doccheckin.asp  $
  '  ------------------------------------------------------------
  '  All Rights Reserved.  Copyright (c) 1988-1998 FileNET Corp.
  '  ------------------------------------------------------------
  '%>
<!-- #include file="islogon.asp" -->
<!-- #include file="jscriptfix.asp" -->
<!-- #include file="notimpl.asp" -->
<!-- #include file="convtohints.asp" -->
<!-- #include file="checkutil.asp" -->

<%
    '
    ' Get User/Session Info
    '
    RequestMethod = Request.ServerVariables("REQUEST_METHOD")
    if RequestMethod = "POST" then
        Ident = Request.Form("Ident")
        Update = Request.Form("Update")
        Status = Request.Form("Status")
        AddFlag= Request.Form("SubmitFlag")
        ShowHints = Request.Form("ShowHints")
    else
        Ident = Request.QueryString("Ident")
        Update = Request.QueryString("Update")
        Status = Request.QueryString("Status")
        AddFlag= Request.QueryString("SubmitFlag")
        ShowHints = Request.QueryString("ShowHints")
    end if 
    if AddFlag = "1" then
        AddFlag = 1
    else 
        AddFlag = 0
    end if
    if not IsNull(ShowHints) then
      if ShowHints = "on" then
        Session("ShowHints") = 1
      else 
        Session("ShowHints") = 0
      end if
    end if

    ShowHintsFlag = Session("ShowHints")
    'Panagon IDM Web application uses the Session variable LibraryLogonID to keep track of
    'whether the user has logged on.
    'Please see logoncall.asp to see how the Session variable LibraryLogonID is set.
    LibraryLogonID = Session("LibraryLogonID")
    set LibraryObj = Server.CreateObject("IDMObjects.Library")
    LibraryObj.LogonID = LibraryLogonID
    set DocObj = LibraryObj.GetObject(Application("idmObjTypeDocument"), Ident)

    '
    ' Validate that this is an IDM Document Services and not an IDM Image Services 
    '
    ' For now, we're only supporting adding to IDM Document Services.
    '
    '
    if LibraryObj.SystemType = Application("idmSysTypeIS") then
%>
<HTML>
    <HEAD>
        <TITLE>EDM-specific page</TITLE>
    </HEAD> 
    <BODY>
    <H2>Redirecting to property screen</H2>
    You are currently logged into an IDM Image Services Library and trying to use a Document Services page.
    </BODY>
</HTML>
<%
    '
    ' We don't want to display any more, because we're on the wrong page
    '
    Response.End
    end if
    '
    '
    if AddFlag = 0 then
    '
    ' Now we perform the first stage of checking in a document, which is to modify the properties
    '
%>

<SCRIPT LANGUAGE="JavaScript">
<!--
// call MultiValue Property page
function MayPickMVProperty(docid, index, ObjType)
{

  // location.href = "mz_MVPMayPick.asp?Type="+ObjType+"&DocID=" + docid + "&PropIndex=" + index;
    document.propenter.PropIndex.value=index;
    document.propenter.UpdateFlag.value = "0";
    document.propenter.action = "mz_MVPMayPick.asp";
    document.propenter.submit();
}
//-->
</SCRIPT>


<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>

<head>
<meta http-equiv="Content-Type"
content="text/html">
<meta name="GENERATOR" content="Microsoft FrontPage 2.0">
<title>Checkin Document</title>
</head>

<body bgcolor="#FFFFFF">

<%

set Props = DocObj.Properties
if Status <> "" and Status <> "1" then
    SubmittedValues = Session("SubmittedValues")
    ValidationStatus = Session("ValidationStatus")
end if
IsVirtual = false
%>

<font size="3"><strong><em>Checkin Document <%= Ident %> : <%=Server.HTMLEncode(DocObj.Label) %></em></strong></font>


<form name="propenter" action="doccheckin.asp" method="POST">
<table border="0" cellpadding="0" cellspacing="1">
    <input type="hidden" name="Type" value="<%= Application("idmObjTypeDocument") %>">
    <input type="hidden" name="Ident" value="<%= Ident %>">
    <tr>
    <td>&nbsp;</td>
    <td colspan=4>
    <input type="checkbox" name="ShowHints" language="JavaScript" onclick="ShowPropertyHints()"
        <% if ShowHintsFlag then %>checked<% end if %>><font size=2>Show Property Hints</font>
    </td>
    </tr>
</table>
<br>
<% IEBrowser = InStr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE")
if IEBrowser then %>
<table frame="box" rules="groups" border="1" cellpadding="0" cellspacing="1">
<% else %>
<table frame="box" rules="groups" border="0" cellpadding="0" cellspacing="1">
<% end if %>
<COLGROUP>
    <COL SPAN="3" ALIGN="left">
<COLGROUP>
    <COL SPAN="3" ALIGN="left">
<THEAD>
    <tr>
        <td align="center" width="30" bgcolor="#EECCFF">&nbsp;</td>
        
        <td align="center" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" width="200" bgcolor="#EECCFF"><font
        size="3"><strong>Property</strong></font></td>
        <td align="center" width="200" bgcolor="#EECCFF"><font
        size="3"><strong>Value</strong></font></td>
        <td align="center" width="12" bgcolor="#EECCFF">&nbsp;</td>
        <td align="center" width="12" bgcolor="#EECCFF">&nbsp;</td>
        
    </tr>
<TBODY>
    <% ' enumerate through the document Properties, to display their names and values

    for i=1 to Props.Count
        set Prop = Props(i)
        set PropDesc = Prop.PropertyDescription
        if PropDesc.Name <> "idmDocCheckouts" then
        %>
    <tr>
    <td valign=top align=right></td>
    
    <td valign=top align=left>
    <% 
    delName="DELETE_" + UCase(Prop.Name) ' used for MultiValue Props
    addName="ADD_" + UCase(Prop.Name)    ' used for MultiValue Props
    propName=Prop.Name
    IsReadOnly = PropDesc.GetState(Application("idmPropReadOnly"))
    if PropDesc.GetState(Application("idmPropRequired")) then ' 5=idmPropRequired
    %>
    <font color="#FF0000" size="3"><strong>*</strong></font>
    <% 
    end if
    if PropDesc.GetState(Application("idmPropVersion")) then 
    %>
    <font color="#FF0000" size="3"><strong>v</strong></font>
    <%  end if %>
    </td>

    <td valign=top><em><%= Prop.Label %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</em></td>
    <td valign=top>
    <% value = ""
       if Status <> "" and Status <> "1" then
            value = SubmittedValues(i)
       end if
     %>  
    <!-- #include file="mz_ValueString.asp" --> 

        <%
       ' depending on property type, a different control is used to enter the property value
       if IsReadOnly then 
            v = Prop.FormatValue 
        if v = "Null" then %>
        <%= value %>
        <% else %>
        <%= v %>
        <% end if

       ' case of multivalue property ========================
       elseif PropDesc.GetState(Application("idmPropMultiValue")) then 
            set MVProp = Prop.Value ' object is a MultipleValues
            
            if ( PropDesc.GetState(Application("idmPropMustPick"))) then
            ' should set the selected values and display all Choices
            ' is there a selection list for this Multi Value Prop ?
             IsChoicePaging = PropDesc.GetState(Application("idmChoicePaging"))
             if IsChoicePaging  then 
                set Choices = PropDesc.Choices
                set oPaging = Choices.Paging
                iPage=1
                'PageSize=50 ' update this value along with "if Choices.Count=50 then" below
                'oPaging.Size=PageSize ' number of choices to retrieve, default is 50
                call oPaging.NextPage(NULL,1) ' idmForward is default
                Count=Choices.Count

            %>
                <%= value %> <br>
                <select multiple name="<%= addName %>" size="3">
        
            <%
                ' if property not required, allow also empty string as choice =======
                if (not PropDesc.GetState(Application("idmPropRequired"))) then 
                %>
                <option value=""<% if ""=value then %> selected <%end if%> > </option>
                <%
                end if
                ' =====
                do until Count=0
                    for k=iPage to Choices.Count
                        ChoiceStrVal = PropDesc.FormatValue(Choices.Item(k).Value)
            %>
            <option value="<%= ChoiceStrVal %>" 
                <% if Request.Form(addName).Count > 0 then ' ===== check against FORMs param
                        for m=1 to Request.Form(addName).Count
                            ' if not (Request.Form(addName)(m) = "") then
                                ThisStrVal = Request.Form(addName)(m)
                                if ChoiceStrVal=ThisStrVal then %> 
                                    selected     <% exit for 
                                end if
                            ' end if 
                        next
                       else 
                        for m=1 to MVProp.Count 
                            ThisStrVal = PropDesc.FormatValue(MVProp.Item(m))
                            if ChoiceStrVal=ThisStrVal then %> 
                                selected     <% exit for
                            end if
                        next
                       end if
                    %>
                 > <%= ChoiceStrVal %> </option>
            <%
                    next


                ' need to check if MORE choices
                  if Choices.Count=50 then  ' check against the preset PageSize
                    iPage=2 ' to skip the first element in the results list (the search key)
                    call oPaging.NextPage(Choices.Item(k - 1).Value, 1)
                    Count=Choices.Count
                  else Count=0
                  end if
                loop
            %>

                </select>
            <% end if
            else ' MayPick values entered in MultiValue Property page ================
            %>
                <%= value %>
                <% for p=1 to Request.Form(delName).Count %>
                <INPUT TYPE=hidden name="<%=delName%>" value="<%= Request.Form(delName)(p) %>">
                <% next %>
                <% for p=1 to Request.Form(addName).Count %>    
                <INPUT TYPE=hidden name="<%=addName%>" value="<%= Request.Form(addName)(p) %>"> 
                <% next %>
            
            <% end if %>
                
        <%
        ' case of single value property with the type: must set by ID ====================
        elseif PropDesc.GetState(Application("idmPropMustSetByID")) then
            ' is there a selection list 
            IsChoicePaging = PropDesc.GetState(Application("idmChoicePaging"))
            if IsChoicePaging   then 
                set Choices = PropDesc.Choices 
                set oPaging = Choices.Paging
                call oPaging.NextPage(NULL,1) ' idmForward is default
                Count=Choices.Count
                if Request.Form(propName).Count > 0 then ' ===== check against FORMs param
                    thisVal=PropDesc.FormatValue(CLng(Request.Form(propName)))
                else
                    thisVal=Prop.FormatValue
                end if
        %>
            <select name="<%= Prop.Name %>" size="1">
        <%
                for k=1 to Choices.Count
                    ChStrVal = PropDesc.FormatValue(Choices.Item(k).Value)

        %>
                
            <option value="<%= Choices.Item(k).Value %>" <% if thisVal=ChStrVal then %> selected <%end if%> > <%= ChStrVal %> </option>
        <%
                next
        %>
            </select>
        <%
            end if
        ' case of single value property w/ selection list
        elseif PropDesc.GetState(Application("idmPropHasCVL")) then 
            ' is there a selection list 
            IsChoicePaging = PropDesc.GetState(Application("idmChoicePaging"))
            if IsChoicePaging   then 
                set Choices = PropDesc.Choices
                set oPaging = Choices.Paging
                iPage=1
                'PageSize=50 ' update this value along with "if Choices.Count=50 then" below
                'oPaging.Size=PageSize ' number of choices to retrieve, default is 50
                call oPaging.NextPage(NULL,1) ' idmForward is default
                Count=Choices.Count
                if Request.Form(propName).Count > 0 then ' ===== check against FORMs param
                    thisVal=Request.Form(propName) ' if date, it is already formatted
                else
                    thisVal=value
                end if
        %>
            <select name="<%= Prop.Name %>" size="1">
                <% 
                if (not PropDesc.GetState(Application("idmPropRequired"))) then %>
            <option value=""<% if ""=thisVal then %> selected <%end if%> > </option>
                <% end if %>
        <%
                do until Count=0
                    for k=iPage to Choices.Count
                        StrVal = PropDesc.FormatValue(Choices.Item(k).Value)
        %>
            <option value="<%= StrVal %>" <% if UCase(StrVal)=UCase(thisVal) then %> selected <%end if%> > <%= StrVal %> </option>
        <%
                    next
                ' need to check if MORE choices
                  if Choices.Count=50 then  ' check against PageSize
                    iPage=2 ' to skip the search  key
                    call oPaging.NextPage(Choices.Item(k - 1).Value, 1)
                    Count=Choices.Count
                  else Count=0
                  end if
                loop
        %>
            </select>
        <%
            end if
         %>
        
    <% elseif Prop.TypeID = Application("idmTypeBoolean") then %>
        <select name="<%= Prop.Name %>" size="1">
            <option value="1" <% if value = 1 then %>selected<% end if %>>True</option>
            <option value="0" <% if value = 0 then %>selected<% end if %>>False</option>
        </select>

    <% 
    ' case of single value string entered as input TEXT ====================
    else 
            FieldSize = PropDesc.Size
    %>
        <input type="text" size="50" name="<%= Prop.Name %>"
            <% if FieldSize > 0 then %>
            maxlength=<%= FieldSize %>
            <% end if %>
            <%
            ' check if the value comes from the request form or the already set value
            if Request.Form(propName).Count > 0 then ' ===== check against FORMs param
            %>
                value="<%= Request.Form(propName) %>"
            <% else %>
                value="<%= value %>"
            <% end if %>
            
            <% if PropDesc.TypeID = Application("idmTypeDate") then %>
            onBlur="CheckDate(this, '<%=value%>')"
            <% elseif PropDesc.TypeID = Application("idmTypeLong") or PropDesc.TypeID = Application("idmTypeShort") _ 
             or PropDesc.TypeID = Application("idmTypeSingle") _
             or PropDesc.TypeID = Application("idmTypeUnsignedShort") or PropDesc.TypeID = Application("idmTypeUnsignedLong")   then %>
            onBlur="CheckInteger(this, '<%=value%>')"
            <% end if %>

            <% if PropDesc.GetState(Application("idmPropRequired")) then %>
            onChange="CheckSelected(this)"
            <% end if %>
            >
    <% end if %>
    </td>

    <td valign=top nowrap>
    <% if (not IsReadOnly) then %>
        <% 
        if Prop.TypeID=Application("idmTypeObject") then
            if (not PropDesc.GetState(Application("idmPropMustPick"))) then 
         %>
        <a target="View" HREF="javascript:MayPickMVProperty('<%=Ident%>','<%=i%>',<%=Application("idmObjTypeDocument")%>)">
    <img alt="Modify MultiValued Property" src="images/smodify.gif" align=bottom border=0 width=24 height=22></a>
            <% end if %>
        <% elseif ShowHintsFlag then %>
            <font size="2">(<%= ConvertToHints(Application("idmObjTypeDocument"), PropDesc) %>)</font>
        <% end if %>
    <% end if %>
    </td>
    <td valign=top nowrap>
    <% if Status = "-1" then
            if ValidationStatus(i) = "-1" then %>
                <font color="#AA0000" size="2"><strong><=== <em>Invalid</em>, was <%= Prop.Value %></strong></font>
    <%      end if
       end if %>
    </td>

    </tr>
    
    <% 
        end if
    next %>
</table>
<%
if IEBrowser then %>
<br>
<% else %>
<hr>
<% end if %>
<table border="0" cellpadding="0" cellspacing="1">
    <tr>
    <td width="30" valign=bottom align=right></td>
    <td>
    <% if not IsVirtual then %>
    <a href="javascript:ChooseFile()"><img src="images/handdoc.gif" alt="Proceed to Choose a Document"  align=bottom border=0 width=47 height=43></a><em><strong>Choose a document...</strong></em>
    <% end if %>
    </td>
    </tr>
</table>
<input type="hidden" name="UpdateFlag" value="1">
<input type="hidden" name="SubmitFlag" value="0">
<input type="hidden" name="PropIndex" value="">
<input type="hidden" name="CheckIn" value="Yes">
</form>
&nbsp;<br>
</body>
</html>

<SCRIPT LANGUAGE="JavaScript">
<!--
function ChooseFile()
{
    document.propenter.SubmitFlag.value = "1";
    document.propenter.UpdateFlag.value = "0";
    document.propenter.submit();
}

function ShowPropertyHints()
{
    document.propenter.SubmitFlag.value = "0";
    document.propenter.UpdateFlag.value = "0";
    document.propenter.submit();
}

function ValidateProps()
{
    document.propenter.SubmitFlag.value = "0";
    document.propenter.UpdateFlag.value = "0";
    document.propenter.submit();
}

function Update()
{
    document.propenter.SubmitFlag.value = "0";
    document.propenter.UpdateFlag.value = "1";
    document.propenter.submit();
}

//-->
</SCRIPT>

<!-- #include file="mz_checksel.asp" -->

<%
    Response.End
    end if
    '
    '  We have all the properties we need, print out the properties for viewing,
    '  not adding or modifying (No Edit mode), and print out an upload form.
    '
%>
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<meta name="GENERATOR" content="">
<title>Add Document: Select File</title>
</head>
<body bgcolor="#FFFFFF">

<font size="3"><strong><em>Checkin Document <%= Ident %> : <%=Server.HTMLEncode(DocObj.Label) %></em></strong></font>
<p>


<% set PropDescs = DocObj.ClassDescription.PropertyDescriptions %>


<FORM NAME="docupload" ACTION="docUpload.dll" METHOD="POST" ENCTYPE="multipart/form-data">
<!-- begin hidden parameters 
   - these parameters are passed to the actual upload isapi dll-->
            <input type=hidden name="library" value="<%=LibraryObj.Name%>">
            <input type=hidden name="doctype" value="<%=DocClass%>">
            <input type=hidden name="logonid" value="<%=LibraryLogonID%>">
<% for each x in Request.Form
    PropName = x
    for i = 1 to Request.Form(x).Count 
    PropValue= Request.Form(x).item(i) 
        if Left(PropName,3) = "IDM" then %>
            <input type=hidden name="property" value="<%=PropName%>">
            <input type=hidden name="value" value="<%=PropValue%>"><%
        else %>
            <input type=hidden name="<%=PropName%>" value="<%=PropValue%>">
<%
        end if
    next 
   next %>

<!-- end hidden parameters -->
<table border=0 width=400>
  <tr>
    <td>
      <input type=checkbox name="index" CHECKED> Index document for content searching.
    </td>
  </tr>
  <tr>
    <td>
      <input type=checkbox name="security"> Modify security. 
    </td>
  </tr>
</table>
    <input type="file" name="filename" value="" size=60>
<br><br><hr>
<a href="javascript:document.docupload.submit()"><img border=0 type="submit" src="images/ckin.gif" value="Check In"></a><strong><em>Check In</em></strong>
</form>
</body>
</html>